function QQ = cost_mat(ts)
%UNTITLED5 Summary of this function goes here
%   Detailed explanation goes here
m = length(ts);

Q = zeros(10);
Q(1,1) = 9144576/11;
Q(1,2) = 1016064/2;Q(2,1) = Q(1,2);
Q(2,2) = 313600;
Q(1,3) = 564480/2;Q(3,1) = Q(1,3);Q(2,3) = 352800/2;Q(3,2) = Q(2,3);
Q(1,4) = 272160/2;Q(4,1) = Q(1,4);
Q(3,3) = 100800;
Q(2,4) = 172800/2;Q(4,2) = Q(2,4);Q(1,5) = 103680/2;Q(5,1) = Q(1,5);
Q(3,4) = 100800/2;Q(4,3) = Q(3,4);Q(2,5) = 67200/2;Q(5,2) = Q(2,5);
Q(1,6) = 24192/2;Q(6,1) = Q(1,6);
Q(4,4) = 25920;
Q(3,5) = 40320/2;Q(5,3) = Q(3,5);Q(2,6) = 16128/2;Q(6,2) = Q(2,6);
Q(4,5) = 21600/2;Q(5,4) = Q(4,5);Q(3,6) = 10080/2;Q(6,3) = Q(3,6);
Q(5,5) = 4800;
Q(4,6) = 5760/2;Q(6,4) = Q(4,6);Q(5,6) = 2880/2;Q(6,5) = Q(5,6);
Q(6,6) = 576;

QQ = zeros(10*(m-1),10*(m-1));

for k=1:m-1
   T1 = zeros(10);
   T1(1:6,1:6) = comp_T(ts(k));
   T2 = zeros(10);
   T2(1:6,1:6) = comp_T(ts(k+1));
   T = T2-T1;
   QQ(10*(k-1)+1:10*k,10*(k-1)+1:10*k) = Q.*T;
end

